import { Redirect } from 'umi'
import useAuth from '../hooks/useAuth'
export default (props:any) => {
  const  data  = useAuth();
  // console.log(data,'data');
  /*可能是真在加载 */
  if ( Array.isArray(data) ){
    if (data.length !== 0) {
      if ( data[0].role > 1 ){
        return <div>{ props.children }</div>;
      } else {
        return <div> <img src="../../public/403.png" alt=""/> </div>
      }
    } else {
      return <Redirect to="/login" />;
    }
  } else {
    return <div> 正在加载 </div>
  }
  
}